package com.quick.mybatis.mapper;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;
import org.springframework.stereotype.Repository;

import com.quick.mybatis.model.PageModel;
import com.quick.mybatis.sqlprovider.CommonProvider;


@Repository("commonCacheMapper")
public interface CommonCacheMapper<T> {
	
	@Options(flushCache = true, timeout = 20000)  
	@UpdateProvider(type = CommonProvider.class, method = "getUpdateSql")
	public Integer update(T t);

	@SelectProvider(type = CommonProvider.class, method = "getInsertSql")
	@Options(flushCache = true, timeout = 20000)  
	public Integer insert(T t);

	@SelectProvider(type = CommonProvider.class, method = "getAllInsertSql")
	@Options(flushCache = true, timeout = 20000)
	public Integer insertAll(List<T> list);

	@DeleteProvider(type = CommonProvider.class, method = "getDeleteSql")
	@Options(flushCache = true, timeout = 20000)
	public Integer delete(T t);

	@Options(useCache = true, flushCache = false, timeout = 10000) 
	@SelectProvider(type = CommonProvider.class, method = "getPageListSql")
	public List<Map<String,Object>> getPageList(PageModel<T> t);

	@SelectProvider(type = CommonProvider.class, method = "getListSql")
	@Options(useCache = true, flushCache = false, timeout = 10000) 
	public List<Map<String,Object>> getList(T t);

	@SelectProvider(type = CommonProvider.class, method = "getPageListCountSql")
	@Options(useCache = true, flushCache = false, timeout = 10000) 
	public Integer getPageListCount(PageModel<T> t);

	@SelectProvider(type = CommonProvider.class, method = "getListAllSql")
	@Options(useCache = true, flushCache = false, timeout = 10000) 
	public List<Map<String,Object>> getListAll(T t);

	@SelectProvider(type = CommonProvider.class, method = "getByIdSql")
	@Options(useCache = true, flushCache = false, timeout = 10000) 
	public Map<String,Object> getById(T t);
}
